#ifndef OBJECT3D_H
#define OBJECT3D_H

/*!
 * \file object3d.h
 * \brief Header of class CObject3D
 * \author Benjamin Toueg
 * \version 20.05.09
 */

#include <SFML/System.hpp>

#include <assert.h>

#include "quadruplet.h"
#include "trajectory.h"
#include "vector3.h"

class CGlobalManager;

/*! \class CObject3D
* \brief Base class of all 3D objects
*/
class CObject3D
{
public:
    CObject3D(CGlobalManager * pGM = NULL): m_pGlobalManager(pGM),
                                            m_pos_tracker_ptr(NULL),
                                            m_rot_tracker_ptr(NULL) {}
    CObject3D(const CObject3D& copy);
    virtual ~CObject3D();
    const sf::Clock*                getClockPtr() const { return &m_clock; } // pas sûr que ce soit utile dans la mesure on il y a trop de const pour pouvoir modifier quoi que ce soit
    const Quadruplet<Vector3d>&     getPosition() const { return m_position; }
    const Quadruplet<Vector3d>&     getRotation() const { return m_rotation; }
    virtual void                    setCurrentPos(const int& z, const int& xy); //inline
    virtual void                    setGlobalManagerPtr(CGlobalManager* pGM) { assert(m_pGlobalManager); m_pGlobalManager = pGM; };

protected:
    CGlobalManager* m_pGlobalManager;
    Quadruplet<Vector3d> m_position;
    TrajectoryCalculator<double>* m_pos_tracker_ptr; // interface
    Quadruplet<Vector3d> m_rotation;
    TrajectoryCalculator<double>* m_rot_tracker_ptr; // interface
    sf::Clock m_clock;
};

inline void CObject3D::setCurrentPos(const int& z, const int& xy)
{
    int dy = (z+1)/2; // decalage
    int dx = -z/2; // decalage
    m_position.current = Vector3d(xy+dx,dy+xy,z);
}

#endif //OBJECT3D_H
